{% extends "base.html" %}

{% block description %}A listing of the top 50 projects on PyPI and whether
they support Python 3{% endblock %}

{% block header %}
<h2>{{ on_py3k / 50 * 100 | round(1) }}% of the top 50 projects based on
    {{ property_name }} are!</h2>
{% endblock %}

{% block body %}
<table>
    <tr>
        <th>Project</th>
        <th id="progress-background">On Python 3?</th>
        <th><a href="/download_rate">Downloads / Day</a></th>
        <th><a href="/download_total">Total Downloads</a></th>
    </tr>
    {% for project in projects %}
    <tr>
        <td><a href="{{ project.cheeseshop_url }}">
                {{ project.name }} {{ project.version }}</a></td>
        <td class="status status_{{ project.py3k_status }}">
            {% if not project.proof %}
               {{ project.py3k_status }}
            {% else %}
               <a href="{{ project.proof }}">{{ project.py3k_status }}</a>
            {% endif %}
        </td>
        <td class="statistic">{{ project.download_rate|round(1) }}</td>
        <td class="statistic">{{ project.download_total }}</td>
    </tr>
    {% endfor %}
</table>

<script>
    var py3k_percent = {{ on_py3k }} / 50;
    var colour_green = Math.round(255 * py3k_percent);
    var colour_red = Math.round(255 - colour_green);
    var background_colour = 'rgb(' + colour_red + ',' + colour_green + ',0)';
    var header_row = document.querySelector('#progress-background');
    header_row.style.backgroundColor = background_colour;
</script>
{% endblock %}
